package com.manage.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.manage.mapper.FlowerUserMapper;
import com.manage.pojo.FlowerUser;
import com.manage.service.FlowerUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 */
@Service
public class FlowerUserServiceImpl extends ServiceImpl<FlowerUserMapper, FlowerUser> implements FlowerUserService {

    @Override
    public Object updateStatus(String status_btn, String userId) {
        Integer userStatus = Integer.valueOf(status_btn.substring(0, 1));
        FlowerUser flowerUser = new FlowerUser();
        flowerUser.setUserId(userId);
        flowerUser.setUserStatus(userStatus);
        return updateById(flowerUser);
    }

    /**
     * 根据用户昵称查询用户
     *
     * @param userName
     * @return
     */
    @Override
    public List<FlowerUser> search(String userName) {
        List<FlowerUser> list = list(Wrappers.<FlowerUser>lambdaQuery().like(FlowerUser::getUserName, userName));
        return list;
    }

    /**
     * 分页查询
     *
     * @param current_page
     * @return
     */
    @Override
    public IPage<FlowerUser> pageList(Integer current_page) {
        Page page = new Page<>(current_page,8);
        page = page(page);
        return page;
    }
}
